#include "../thirdparty/cJSON.h"
#include <stdio.h>

int main(void)
{
    char *json_str = "{\"dir\":\"forward\" , \"speed\":\"500\"}";
    cJSON* object = cJSON_Parse(json_str);
    cJSON* dir = cJSON_GetObjectItem(object,"dir");
    cJSON* speed = cJSON_GetObjectItem(object,"speed");
    char* dir1  = cJSON_GetStringValue(dir);
    char* speed1 = cJSON_GetStringValue(speed);
    printf("dir=%s\n",dir1);
    printf("speed=%s\n",speed1);
    cJSON_Delete(object);
    cJSON* object1 = cJSON_CreateObject();
    cJSON_AddStringToObject(object1,"dir","forward");
    cJSON_AddNumberToObject(object1,"speed",500);
    char* json_str2 = cJSON_PrintUnformatted(object1);
    printf("json_str:%s\n",json_str2);
    cJSON_Delete(object1);
    return 0;
}